import "babel-polyfill";
import Vue from "vue";
import VueRouter from "vue-router";
import store from "src/store/index";
import * as filters from "src/config/filters";
import routes from "src/router/routes-pc";
import { sync } from "vuex-router-sync";
import App from "src/views/app.vue";
import VueResource from "vue-resource";
import _ from "lodash";
import "assets/less/main.less";
import Element from "element-ui";

Vue.use(Element);
Vue.use(VueRouter);
Vue.use(VueResource);

/* loading commpents */
Object.keys(filters).forEach(k => Vue.filter(k, filters[k])); //注册过滤器

Vue.config.devtools = true;
Vue.config.silent = true;

Vue.prototype._ = _;

//路由跳转
const router = new VueRouter({
  routes,
  mode: "hash",
  base: window.location.pathname ? window.location.pathname : __dirname,
  linkActiveClass: "router-link-active" //将激活的路由添加一个mui-active类名称
});

router.beforeEach(({ path }, from, next) => {
  next();
});
router.afterEach(route => {});

sync(store, router);

//挂载首页
// new Vue({ router, render: h => h(App) }).$mount('#app')

const app = new Vue({
  router,
  store,
  ...App
});

app.$mount("#myApp");
